home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mail / BounceIt.lha / BounceIt.rexx < prev   
OS/2 REXX Batch file  |  1995-04-17  |  5KB  |  173 lines

  1. /******************************************************************************
  2.  
  3. BounceIt V1.00
  4.  
  5. Copyright © 1995 by Greg Patterson
  6.  
  7.  
  8. This program scans your inbound UUMAIL: directory for mail delivered to your
  9. site.  It uses a very simple configuration file in amitcp:db/bounce.config upon
  10. startup.  Any files found in the UUMAIL: directory which are not listed in this
  11. configuration file will be bounced to a destination email address.
  12.  
  13. For example, on my system, I have Sabot setup to alert me to any incoming email
  14. for the userid's "root" or "christina".  If I receive email on any other
  15. address on my machine, it will often stay around for days without being
  16. noticed.
  17.  
  18. Using this program, I have placed the above userid's in my
  19. amitcp:db/bounce.config file.  Any emails sent to userid's not listed in the
  20. configuration file get automatically bounced to "root" (or BouncerDest) when
  21. this program is run.
  22.  
  23. Set this program up to be run from a CRON utility or possibly in-conjunction
  24. with the Sabot utility.
  25.  
  26.  
  27. File layout of amitcp:db/bounce.config:
  28.  
  29. +--- File format ---
  30. |root
  31. |christina
  32. +-------------------
  33.  
  34. Nothing fancy!  Do not place spaces before or after each line and make sure
  35. you don't put any blank lines in the configuration file.  This program does
  36. little or no error checking!
  37.  
  38.  
  39. Description of configuration variables below:
  40.  
  41. BouncerCmd:
  42.    Your mailer command (usually Elm).  Whatever you use must put From:, To:
  43.    and Subject: headers (ie. don't use SMTPPost!).  It must also accept input
  44.    from stdin.  You may need to modify other parameters which are customized
  45.    specifically for Elm.  Refer to the source code.
  46.  
  47. BouncerId:
  48.    UserId which initiates the sending of the bounced email.
  49.  
  50. BouncerDest:
  51.    UserId to send the bounced email to.
  52.  
  53. BouncerSubject:
  54.    Subject for each bounced email.
  55.  
  56. BouncerDir:
  57.    Directory which is to be checked for bounced email.  Append a slash (/)
  58.    to the directory name if necessary (ie. if the last character is not a
  59.    colon).
  60.  
  61. BouncerKill:
  62.    If this variable is set to "1", it will delete any files found in the
  63.    BouncerDir ending in ".o" extension.  These files are backup files
  64.    created by Elm.
  65.  
  66.  
  67. Requirements:
  68.    This program has been hard-coded to use Amiga ELM.  I don't know of any
  69.    other programs which may be used.  Configure this yourself as necessary.
  70.  
  71.    Obviously you need ARexx.
  72.  
  73.    Configuration file in AmiTCP:db/bounce.config must exist.
  74.  
  75. ##############################################################
  76.  
  77. Contact Information:
  78.  
  79.    Email: root@wizard.hip.cam.org
  80.           wizard@cam.org
  81.  
  82.    Mailing address:
  83.  
  84.    4770 Linton Street Appt #5
  85.    Montreal, Quebec
  86.    Canada   H3W 1K1
  87.  
  88. ##############################################################
  89.  
  90. Disclaimer:
  91.  
  92. NO WARRANTIES ARE MADE.  USE OF THIS PROGRAM IS AT YOUR OWN RISK.  NO
  93. LIABILITY OR RESPONSIBILITY IS ASSUMED.
  94.  
  95. ******************************************************************************/
  96.  
  97. Options FailAt 100
  98.  
  99. BouncerCmd     = "AmiTCP:bin/Elm"
  100. BouncerId      = "postmaster"
  101. BouncerDest    = "root"
  102. BouncerSubject = "Bounced Email"
  103. BouncerDir     = "UUMail:"
  104. BouncerKill    = 1
  105.  
  106. /* Open configuration file. */
  107. if ~Open('Fp', 'AMITCP:db/bounce.config', 'Read') then do
  108.    say "Error: Unable to open configuration file 'AmiTCP:db/bounce.config'"
  109.    say ""
  110.    say "WARNING: Since this may be your first time running this program, you"
  111.    say "had better look at the source code for this program before proceeding"
  112.    say "any further.  This program may cause loss of data if you do not setup"
  113.    say "this program correctly!"
  114.    say ""
  115.    exit(30)
  116. end
  117.  
  118. if ~ShowList('L', 'rexxsupport.library') then do
  119.    call AddLib("rexxsupport.library", 0, -30, 0)
  120. end
  121.  
  122. /* Read in userids which should not be bounced. */
  123. IdCnt = 0
  124.  
  125. Line = ReadLn('Fp')
  126. do while ~eof('Fp')
  127.    IdCnt = IdCnt + 1
  128.    SafeId.IdCnt = Line
  129.    Line = ReadLn('Fp')
  130. end
  131.  
  132. /* Read in file names in UUMAIL: directory. */
  133. DirList = ShowDir(BouncerDir, "Files")
  134.  
  135. /* For each file found, process it. */
  136. do i = 1 to Words(DirList)
  137.    File = Word(DirList, i)
  138.  
  139.    /* Ignore any files ending in .o (created by Elm). */
  140.    if Right(File, 2) ~= ".o" then do
  141.       InList = 0
  142.  
  143.       /* Look for userid in bounce list. */
  144.       do s = 1 to IdCnt
  145.          if (File == SafeId.s) then do
  146.             InList = 1
  147.             Break
  148.          end
  149.       end
  150.  
  151.       /* If not in db/bounce.config, bounce it. */
  152.       if ~InList then do
  153.          /* This builds the email command (Elm) to be executed. */
  154.          Cmd = BouncerCmd || ' <' || BouncerDir || File || ' >NIL: -u '
  155.          Cmd = Cmd || BouncerId || ' -s "' || BouncerSubject || '"'
  156.          Cmd = Cmd || ' ' || BouncerDest
  157.  
  158.          address command Cmd
  159.  
  160.          call Delete(BouncerDir || File)
  161.          end
  162.       end
  163.    else do
  164.       if BouncerKill == 1 then do
  165.          call Delete(BouncerDir || File)
  166.       end
  167.    end
  168. end
  169.  
  170. call Close('Fp')
  171.  
  172. Exit(0)
  173.